﻿@model MAPDavy.Entities.AnioLectivo

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Css{
    <link href="@Url.Content("~/Content/css/colorpicker.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/layout.css")" rel="stylesheet" type="text/css" />
}

@section JavaScript{
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/js/colorpicker.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/js/eye.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/js/utils.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/js/layout.js?ver=1.0.2")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.ui.datepicker.js")" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {

            $("#InicioAcademico").datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: 'dd/mm/yy'
            });

            $('#Cerrado').change(function (e) {

                var _checked = $(this).is(':checked');

                $(this).val(_checked);

                $(':hidden[name=Cerrado]').val(_checked);

            });
            
            /*$("#save").click(function () {
                if ($("#Cerrado").is(':checked')) {
                    $('input[name="Cerrado"]').val('TRUE');
                }
                else {
                    $('input[name="Cerrado"]').val('FALSE');
                }
            });*/

            $('#colorSelector0').ColorPicker({
                color: '#0000ff',
                onShow: function (colpkr) {
                    $(colpkr).fadeIn(500);
                    return false;
                },
                onHide: function (colpkr) {
                    $(colpkr).fadeOut(500);
                    return false;
                },
                onChange: function (hsb, hex, rgb) {
                    $('#colorSelector0 div').css('backgroundColor', '#' + hex);
                    $("#Color").val('#' + hex);
                }
            });

            $('#guardar').click(function () {
                $('form').submit();
            });
        });
    </script>
}

<div class="cpanel ui-widget ui-widget-content ui-corner-all">
    <table class="toolbar">
        <tr>
            <td valign="middle" >
                <img src="@Url.Content("~/Content/images/newYear.png")" title="Años Lectivos" alt="Años Lectivos" />
            </td>
            <td class="tdHeader"><span class="header">Registrar Año Lectivo</span></td>
            <td><center>
                <a href="#" id="guardar">
                    <img src="@Url.Content("~/Content/images/save.png")" title="Crear Año Lectivo" alt="Crear Año Lectivo" />
                    <br /><span class="label">Guardar</span>
                </a></center>
            </td>
            <td><center>
                <a href="@Url.Action("Index", "AnioLectivo")">
                    <img src="@Url.Content("~/Content/images/back.png")" title="Crear Año Lectivo" alt="Crear Año Lectivo" />
                    <br /><span class="label">Cancelar</span>
                </a></center>
            </td>
        </tr>
    </table>
</div>
@if (ViewData["message"]!="")
   {
       <h3>
        <span class="field-validation-error">
            @ViewData["message"] 
        </span>
      </h3>
   }
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>AnioLectivo</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Anio,"Año:")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Anio, new { @readonly = "true" })
            @Html.ValidationMessageFor(model => model.Anio)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Descripcion,"Descripción:")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Descripcion)
            @Html.ValidationMessageFor(model => model.Descripcion)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.InicioAcademico,"Inicio Académico:")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.InicioAcademico)
            @Html.ValidationMessageFor(model => model.InicioAcademico)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NroDiasClase,"Nro. Dias de Clase:")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.NroDiasClase)
            @Html.ValidationMessageFor(model => model.NroDiasClase)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Color)
        </div>            
        <div class="editor-field">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        @Html.TextBoxFor(model => model.Color, new { @readonly = "readonly" })
                    </td>
                    <td>
                        @if (@Model == null)
                        {
                            <div id="colorSelector0"><div style="background-color: #0000ff"></div></div> 
                        }
                        else 
                        {
                            <div id="colorSelector0"><div style="background-color: @Model.Color"></div></div> 
                        }  
                    </td>
                </tr>
            </table>           
                

            @Html.ValidationMessageFor(model => model.Color)
        </div>

        <div class="editor-field">
            @Html.LabelFor(model => model.Cerrado, "Cerrado:")
            @Html.CheckBoxFor(model => model.Cerrado)
            @Html.ValidationMessageFor(model => model.Cerrado)
        </div>
    </fieldset>
}
